import request from '@/axios'
import { ArticleParams, ArticleResponse, ArticleItem } from './types'

export const getArticleApi = (params: ArticleParams) => {
  return request.get<ArticleResponse>({ url: '/article/list', params })
}

export const deleteArticleByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/article/delete', data: { ids } })
}

export const saveArticleApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/article/edit' : '/article/add',
    data
  })
}

export const getArticleByIdApi = (data: any) => {
  return request.get<ArticleItem>({ url: '/article/detail?id=' + data })
}
